﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Admin/MasterPages/Default.Master" CodeBehind="Default.aspx.vb" Inherits="GuildCMS.Admin.News._Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:Label ID="lblNewsList" runat="server" Text="List of Current News Items:"></asp:Label>
    <asp:ListView runat="server"
        ID="lvNewsItems"
        DataSourceID="SqlDataSource1"
        DataKeyNames="Item_Id">
        <LayoutTemplate>
            <asp:PlaceHolder runat="server" ID="itemPlaceHolder" />
        </LayoutTemplate>  
        <ItemTemplate>
            <div>
                <asp:LinkButton ID="btnActive" CommandName="Edit" runat="server">edit</asp:LinkButton>
                <asp:LinkButton ID="btnDelete" CommandName="Delete" OnClientClick="return confirm('Are you certain you want to delete this item?');" runat="server">delete</asp:LinkButton>
                <asp:Label ID="lblStatus" runat="server"><%# Eval("Item_Active")%></asp:Label>
                <asp:Label ID="lblHeadline" runat="server"><%# Eval("Item_Headline")%></asp:Label>
                <asp:Label ID="lblCategory" runat="server"><%# Eval("Category_Name")%></asp:Label>
                <asp:Label ID="lblAuthor" runat="server"><%# Eval("Item_Author")%></asp:Label>
                <asp:Label ID="lblDate" runat="server"><%# Eval("Item_Date")%></asp:Label>
            </div>
        </ItemTemplate>
        <AlternatingItemTemplate>
            <div>
                <asp:LinkButton ID="btnActive" CommandName="Edit" runat="server">edit</asp:LinkButton></td>
                <asp:LinkButton ID="btnDelete" CommandName="Delete" OnClientClick="return confirm('Are you certain you want to delete this item?');" runat="server">delete</asp:LinkButton>
                <asp:Label ID="lblStatus" runat="server"><%# Eval("Item_Active")%></asp:Label>
                <asp:Label ID="lblHeadline" runat="server"><%# Eval("Item_Headline")%></asp:Label>
                <asp:Label ID="lblCategory" runat="server"><%# Eval("Category_Name")%></asp:Label>
                <asp:Label ID="lblAuthor" runat="server"><%# Eval("Item_Author")%></asp:Label>
                <asp:Label ID="lblDate" runat="server"><%# Eval("Item_Date")%></asp:Label>
            </div>
        </AlternatingItemTemplate>
        <EditItemTemplate>
            <div><asp:Label ID="lblHeadline" runat="server" Text="Headline:"></asp:Label></div>
            <div><asp:TextBox ID="txtHeadline" Text='<%# Eval("Item_Headline")%>' runat="server"></asp:TextBox></div>
            <div><asp:Label ID="lblCategory" runat="server" Text="Category:"></asp:Label></div>
            <div>
                <asp:DropDownList runat="server"
                    ID="ddlCategory"
                    DataSourceID="SqlDataSource2"
                    DataTextField="Category_Name"
                    DataValueField="Category_Id"
                    SelectedValue='<%# Eval("Category_Id")%>'>
                </asp:DropDownList>
            </div>
            <div><asp:Label ID="lblBody" runat="server" Text="Body:"></asp:Label></div>
            <div><asp:TextBox ID="txtBody" TextMode="MultiLine" Text='<%# Eval("Item_Body")%>' runat="server"></asp:TextBox></div>
            <div><asp:CheckBox ID="chkActive" Text="Active" Checked='<%# Eval("Item_Active")%>' runat="server" /></div>
            <div><asp:Button ID="btnSave" CommandName="Save" Text="save" runat="server"></asp:Button></div>
        </EditItemTemplate>
    </asp:ListView>

    <%-- 
    <div>
        <asp:DataPager runat="server"
            ID="Pager"  
            PagedControlID="lvNewsItems"
            PageSize="5">                       
            <Fields>
                <asp:NumericPagerField
                    ButtonCount="10"
                    NextPageText="..." 
                    PreviousPageText="..." />
                <asp:NextPreviousPagerField 
                    FirstPageText="First"
                    LastPageText="Last" 
                    NextPageText="Next"
                    PreviousPageText="Previous" />
            </Fields>
        </asp:DataPager>
    </div>
    --%>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SqlConnectionString %>" 
        SelectCommand="sp_admin_getNews" SelectCommandType="StoredProcedure" 
        DeleteCommand="sp_admin_deleteNews" DeleteCommandType="StoredProcedure">
        <DeleteParameters>
            <asp:Parameter Name="Item_Id" Type="Int32" />
        </DeleteParameters>
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SqlConnectionString %>" 
        SelectCommand="sp_admin_getNewsCategories" SelectCommandType="StoredProcedure">
    </asp:SqlDataSource>

</asp:Content>
